package life.huangzhi.community.community.mapper;

import life.huangzhi.community.community.model.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;


/**
 * @author Administrator
 * @date 2019/11/28 20:15
 */
@Mapper
public interface UserMapper {
    @Insert("insert into user(name,account_Id,token,gmt_create,gmt_modified,avatar_url) " +
            "values (#{name},#{accountId},#{token},#{gmtCreate},#{gmtModified},#{avatarUrl})")
    void insertUser (User user);

    @Select("select * from user where token = #{token}")
    User findByToken (@Param("token") String token);

    @Select("select * from user where id = #{id}")
    User findById (@Param("id")Integer id);

    @Select("select * from user where account_id = #{accountId}")
    User findByAccountId(@Param("accountId") String accountId);

    @Update("update user set name = #{name} ,token = #{token},gmt_modified = #{gmtModified},avatar_url = #{avatarUrl}  where id = #{id}")
    void updateUser(User user);
}
